/**
 * 
 */
package edu.bu.grocery.backingbean;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;

import edu.bu.grocery.session.UserSession;
import edu.bu.grocerylist.model.GroceryList;
import edu.bu.grocerylist.model.GroceryUser;
import edu.bu.grocerylist.service.IGroceryListService;
import edu.bu.grocerylist.service.IGroceryUserService;

/**
 * This backing bean represents the GroceryLists page, where the user can see their
 * available GroceryList objects that they can perform as well as how to interact with them
 * @author donlanp
 *
 */
public class ConfirmDeleteGroceryListBackingBean  implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2408207935389475608L;

	private UserSession session;
	
	private IGroceryListService listService;
	
	private IGroceryUserService userService;
	
	private int listIDToDelete;

	@PostConstruct
	public void init(){
		listIDToDelete = session.getCurrentGroceryList().getGroceryListId();
	}
	
	/**
	 * Deletes the selectedlist
	 * @return
	 */
	public String deleteList(){
		System.out.println("I want to delete list..." + listIDToDelete);
		GroceryList list = listService.getGroceryListById(listIDToDelete);
		
		listService.deleteGroceryList(list);
		
		return "grocerylists";
	}
	
	
	//Getters and Setters
	/**
	 * @return the session
	 */
	public UserSession getSession() {
		return session;
	}

	/**
	 * @param session the session to set
	 */
	public void setSession(UserSession session) {
		this.session = session;
	}
	
	public int getListIDToDelete() {
		return listIDToDelete;
	}
	
	public void setListIDToDelete(int listIDToDelete) {
		this.listIDToDelete = listIDToDelete;
	}

	/**
	 * @return the listService
	 */
	public IGroceryListService getListService() {
		return listService;
	}

	/**
	 * @param listService the listService to set
	 */
	public void setListService(IGroceryListService listService) {
		this.listService = listService;
	}

	/**
	 * @return the userService
	 */
	public IGroceryUserService getUserService() {
		return userService;
	}

	/**
	 * @param userService the userService to set
	 */
	public void setUserService(IGroceryUserService userService) {
		this.userService = userService;
	}
}
